﻿//表单自动加载的方法，在表单的js文件文件定义 LoadFormData（）方法
//自动执行另一个js的LoadFormData方法
//如list要执行这个，edit不用调用这个
$(function () {
    FormShown();
    isLimited();
});



function getQueryString(name) {
    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
    var r = window.location.search.substr(1).match(reg);
    if (r != null)
        return unescape(r[2]);
    return null;
}

function CloseWindowBill(action) {
    if (window.CloseOwnerWindow) window.CloseOwnerWindow(action);
    else window.close();
}

function TimeLimited() {
    mini.parse();
    try {
        var rr = mini.getbyName("save");
        mini.getbyName("save").disable();
    }catch(e){
    }
    try {
        var rr = mini.getbyName("SaveInfo");
        mini.getbyName("SaveInfo").disable();
    } catch (e) { }
    try {
        var rr = mini.getbyName("removeRow");
        mini.getbyName("removeRow").disable(); 
    } catch (e) { }
    try{
        mini.getbyName("modify").disable();
    } catch (e) { }
    try{
        mini.getbyName("new").disable();
    } catch (e) { }
    try{
        mini.getbyName("delrow").disable();
    } catch (e) { }
    try{
        mini.getbyName("saveCorp").disable();
    } catch (e) { }
    try{
        mini.getbyName("modifyCorp").disable();
    } catch (e) { }
    try{
        mini.getbyName("check").disable();
    } catch (e) { }
    try {
        mini.getbyName("checkbill").disable();
    } catch (e) { }
    try {
        mini.getbyName("addClass").disable();
    } catch (e) { }
    try{
        mini.getbyName("editClass").disable();
    } catch (e) { }
    try{
        mini.getbyName("removeClass").disable();
    } catch (e) { }
    try {
        mini.getbyName("batch").disable();
    } catch (e) { }
    try{
        mini.getbyName("removebill").disable();
    } catch (e) { }
}

function isLimited() {
    $.post("../Home/IsLimited", { mSystemAppID: parent.window.getSystemAppID() }, function (data) {
        if (data.Success == false)
            TimeLimited();
    });
}

function InitGrid(table) {
    $.post("../Corp/GetHideCol", { json: table, mSystemAppID: parent.window.getSystemAppID() }, function (data) {
        var dataR = mini.decode(data);
        if (dataR.length == 0) return;
        var iCnt = dataR.length;
        var fields = "";
        for (var i = 0; i < iCnt; i++) {
            var col = dataR[i];
            //grid.setColumnWidth(col.field, col.width);
            //grid.updateColumn(col.field, { header: col.header });
            fields = fields + col.FColName + ";";
        }
        var cols = grid.getColumns();
        for (var i = 0; i < cols.length; i++) {
            if (typeof (cols[i].field) == "undefined") continue;
            if (fields.indexOf(cols[i].field) > -1) {
                grid.hideColumn(cols[i].field);
            }
        }
    });
}
